package com.dgh.school.mapper;

import com.dgh.school.bean.Duty;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DutyMapper {

    @Select("select * from duty")
    List<Duty> selectAll() throws Exception;

    // 根据id删除数据
    @Delete("delete from duty where did = #{id}")
    void deleteById(int id) throws Exception;

    // 插入数据
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    @Insert("insert into duty values (default, #{dname}, #{dperson},  #{dfunction})")
    void insert(Duty duty) throws Exception;


    @Update("update duty set dname = #{dname},dperson = #{dperson},dfunction = #{dfunction} where dname = #{dname}")
    void update(Duty duty) throws Exception;

}
